<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">

    <link rel="shortcut icon" href="<!--{eval echo register_static('img/touch-icon-57x57.png');}-->">

    <title>粉粉管理系统</title>

    <!-- Bootstrap core CSS -->
    <link href="<!--{eval echo register_static('css/bootstrap.min.css');}-->" rel="stylesheet">
    <link href="<!--{eval echo register_static('css/bootstrap-reset.css');}-->" rel="stylesheet">

    <!--Animation css-->
    <link href="<!--{eval echo register_static('css/animate.css');}-->" rel="stylesheet">

    <!--Icon-fonts css-->
    <link href="<!--{eval echo register_static('assets/font-awesome/css/font-awesome.css');}-->" rel="stylesheet" />
    <link href="<!--{eval echo register_static('assets/ionicon/css/ionicons.min.css');}-->" rel="stylesheet" />

    <link href="<!--{eval echo register_static('assets/sweet-alert/sweet-alert.min.css');}-->" rel="stylesheet">

    <!-- Plugins css -->
    <link href="<!--{eval echo register_static('assets/modal-effect/css/component.css');}-->" rel="stylesheet">

    <!-- DataTables -->
    <link rel="stylesheet" href="<!--{eval echo register_static('assets/datatables/jquery.dataTables.min.css" rel="stylesheet');}-->" />

    <!-- Custom styles for this template -->
    <link href="<!--{eval echo register_static('css/style.css');}-->" rel="stylesheet">
    <link href="<!--{eval echo register_static('css/helper.css');}-->" rel="stylesheet">

    <!-- My styles for this template -->
    <link href="<!--{eval echo register_static('css/common.css');}-->" rel="stylesheet">

</head>

<body>

<!-- Aside Start-->
<!--{template admin_v2/leftside}-->
<!-- Aside Ends-->


<!--Main Content Start -->
<section class="content">

    <!-- Header -->
    <!--{template admin_v2/header}-->
    <!-- Header Ends -->


    <!-- Page Content Start -->
    <!-- ================== -->

    <div class="wraper container-fluid diarys">

        <div class="row">
            <div class="col-md-12">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h3 class="panel-title">热门点滴待上线列表</h3>
                    </div>
                    <div class="panel-body">
                        <div class="row">
                            <div class="col-md-5 col-sm-5 col-xs-5" id="addDiaryToHotReady">
                                <!-- Search -->
                                <form class="form-inline" role="form" style="float:left;">
                                    <div class="form-group">
                                        <select class="form-control myChoose" name="onlineTime" id="timeOnline">
                                            <option value="no">不可上线</option>
                                            <option value="all">上线时间(全部)</option>
                                            <option value="16">16:00</option>
                                            <option value="20">20:00</option>
                                        </select>
                                    </div>
                                    <div class="form-group">
                                        <input type="text" class="form-control" placeholder="输入BodyId" name="bodyId" value="$_GET[bodyId]">
                                    </div>
                                    <div class="form-group">
                                        <input type="text" class="form-control" placeholder="输入权重" name="score" value="$_GET[score]">
                                    </div>
                                    <button type="button" class="btn btn-success m-l-10 addtohot">点击添加</button>
                                </form>
                            </div>
                            <div class="btn-group m-b-10 select-sheet">
                                <button type="button" href="#" class="btn btn-primary w-xs m-b-5" disabled="disabled">选择上线时间</button>
                                <a type="button" href="javascript:void(0);" name="all" class="btn btn-default">全部</a>
                                <a style="display:none;" type="button" href="javascript:void(0);" name="12" class="btn btn-default">12点</a>
                                <a type="button" href="javascript:void(0);" name="16" class="btn btn-default">16点</a>
                                <a type="button" href="javascript:void(0);" name="20" class="btn btn-default">20点</a>
                            </div>
                            <span>(说明:12点过后添加无效)</span><input id="timet" style="display:none;" value="{$type}"/>
                        </div>

                        <div class="row">
                            <div class="col-md-12 col-sm-12 col-xs-12">
                                <table id="datatable" class="table table-striped table-bordered">
                                    <thead>
                                    <tr>
                                        <th style="width: 5%;">序号</th>
                                        <th style="width: 5%;">作者</th>
                                        <th style="width: 60%;">概览</th>
                                        <th style="width: 5%;">权重值</th>
                                        <th style="width: 5%;">查/评数</th>
                                        <th style="width: 5%;">附件</th>
                                        <th style="width: 7%;">操作</th>
                                    </tr>
                                    </thead>

                                    <tbody>
                                    <!--{loop $list $key=>$diary}-->
                                    <tr id="tr_{$diary['bodyId']}">
                                        <td>
                                            <label class="cr-styled"><input type="checkbox" name="bodyId" value="$diary['bodyId']" class="box"><i class="fa"></i></label>
                                            <a href="javascript:;" class="btn btn-info btn-xs m-b-5"><!--{eval echo ($num + $key) }--></a>
                                        </td>
                                        <td><a href="admin.php?ac=admin&do=accountOperation&uid=$diary['eUid']"  class="btn btn-info btn-xs m-b-5" target="_blank">$diary['eNickname']</a></td>
                                        <td>
                                            <p><a href="admin.php?ac=diary_class&op=getDiaryDetail&bodyId=$diary['bodyId']&uid=$diary['detail']['uid']" target="_blank">
                                                <!--{eval echo biaoqing_replace($diary['content'])}-->
                                            </a></p>
                                            <p>
                                                <!--{if $diary['detail']['topic'][0]['name']}-->
                                                <a href="admin.php?ac=diarytopic_class&op=getDiarysByTopic&gid=$diary['detail']['topic'][0]['id']" class="btn btn-info btn-xs m-b-5">
                                                    #$diary['detail']['topic'][0]['name']
                                                </a>
                                                <!--{/if}-->
                                            </p>
                                        </td>
                                        <td>$diary['score']</td>
                                        <td>{$diary['detail']['viewTimes']} / {$diary['detail']['commentTimes']}</td>
                                        <td>
                                            <!--{if $diary['detail']['attachmentList']}-->
                                            <i class="glyphicon glyphicon-picture"></i>
                                            <!--{/if}-->
                                            <!--{if $diary['detail']['voiceList']}-->
                                            <i class="glyphicon glyphicon-volume-up"></i>
                                            <!--{/if}-->
                                            <!--{if $diary['detail']['videoList']}-->
                                            <i class="glyphicon glyphicon-facetime-video"></i>
                                            <!--{/if}-->
                                        </td>
                                        <td class="actions" data-bodyid="$diary['bodyId']">
                                            <a href="#" class="on-default edit-row btn btn-default btn-sm diaryinfo" data-toggle="modal" data-target="#con-close-modal" data-bodyId="{$diary[bodyId]}" data-score="{$diary[score]}"><i class="fa fa-pencil"></i></a>
                                            <a href="javascript:;"  class="on-default remove-row btn btn-default btn-sm" data-bodyId="{$diary[bodyId]}"><i class="fa fa-trash-o"></i></a>
                                        </td>
                                    </tr>
                                    <!--{/loop}-->
                                    </tbody>
                                </table>
                                <div class="col-md-3 col-sm-3 col-xs-3">
                                    <button class="btn btn-info checkAll">全选/全不选</button>
                                    <button class="btn btn-info batchDelete">批量删除</button>
                                </div>
                                <!--{if $pageUrl}-->
                                <div class="row">
                                    <div class="col-md-12">
                                        <form action="admin.php" method="get">
                                            <div class="input-group m-t-10 col-md-2" style="margin: 0 auto">
                                                <input type="hidden" name="ac" value="diary_class">
                                                <input type="hidden" name="op" value="hotReady">
                                                <div id="spinner4">
                                                    <div class="input-group">
                                                        <div class="spinner-buttons input-group-btn">
                                                            <button type="button" class="btn spinner-down btn-pink">
                                                                <i class="fa fa-minus"></i>
                                                            </button>
                                                        </div>
                                                        <input name="type" style="display:none;" value="{$type}"/>
                                                        <input type="text" name="page" class="spinner-input form-control" maxlength="4"  value="{$pageUrl['currentPage']}">
                                                        <div class="spinner-buttons input-group-btn">
                                                            <button type="button" class="btn spinner-up btn-purple">
                                                                <i class="fa fa-plus"></i>
                                                            </button>
                                                        </div>
                                                    </div>
                                                </div>
                                                <span class="input-group-btn"><button type="submit" class="btn btn-effect-ripple btn-primary">跳转</button></span>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                                <ul class="pager">
                                    <li>
                                        <a href="{$pageUrl['prev']}"> <i class="fa fa-angle-double-left"></i>上一页</a>
                                    </li>
                                    <li>
                                        <a href="{$pageUrl['first']}"> <i class="fa"></i>第一页</a>
                                    </li><li>
                                        <a href="javascript:;"> <i class="fa"></i>当前为{$pageUrl['currentPage']}页，共{$pageUrl['totalPage']}页</a>
                                    </li>
                                    <li>
                                        <a href="{$pageUrl['next']}">下一页 <i class="fa fa-angle-double-right"></i> </a>
                                    </li>
                                </ul>
                                <!--{/if}-->
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

    </div>
    <!-- Page Content Ends -->
    <!-- ================== -->

    <div id="con-close-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">

    </div><!-- /.modal -->


    <!-- Footer Start -->
    <!--{template admin_v2/footer}-->
    <!-- Footer Ends -->



</section>
<!-- Main Content Ends -->


<!-- js placed at the end of the document so the pages load faster -->
<script src="<!--{eval echo register_static('js/jquery.js');}-->"></script>
<script src="<!--{eval echo register_static('js/bootstrap.min.js');}-->"></script>
<script src="<!--{eval echo register_static('js/pace.min.js');}-->"></script>
<script src="<!--{eval echo register_static('js/wow.min.js');}-->"></script>
<script src="<!--{eval echo register_static('js/jquery.nicescroll.js');}-->" type="text/javascript"></script>
<script type="text/javascript" src="<!--{eval echo register_static('assets/spinner/spinner.min.js');}-->"></script>
<script src="<!--{eval echo register_static('js/jquery.app.js');}-->"></script>
<script src="<!--{eval echo register_static('assets/sweet-alert/sweet-alert.min.js');}-->"></script>
<script src="<!--{eval echo register_static('assets/sweet-alert/sweet-alert.init.js');}-->"></script>

<script type="text/javascript">
    $(document).on("click",".remove-row",function(){
        var data = $(this).data();
        var bodyid = data.bodyid;
        var onlineTime = $("#timet").val();
        var tritem = 'tr_'+bodyid;

        $.get(  "admin.php", {
            bodyId : bodyid,
            onlineTime : onlineTime,
            ac	   : 'diary_class',
            op	   : 'delHotDiaryReadyByBodyId'
        },function(data) {
            if (data == 1) {
                $("#"+tritem).hide();
                refresh();
            }
        });
    });

    // 获取点滴话题详情
    $(".diaryinfo").click(function() {
        var diary = $(this).data();
        console.log(diary);
        var bodyId   = diary.bodyid;
        var score   = diary.score;
        var onlineTime = $("#timet").val();
        data = '<div class="modal-dialog"><div class="modal-content"><form role="form"><div class="modal-header"><button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button><h4 class="modal-title">热门权重修改</h4> </div><div class="modal-body"><div class="row"><div class="col-md-12"><div class="form-group no-margin"> <input type="text" class="form-control" id="field-3" placeholder="score" name="score" value="'+score+'"></div></div></div><div class="modal-footer"><input type="hidden" name="bodyId" value="'+bodyId+'"><input type="hidden" name="onlineTime" value="'+onlineTime+'"> <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button><button type="button" class="btn btn-info editdiary">保存</button></div></form></div></div>'
        $("#con-close-modal").empty();
        $("#con-close-modal").append(data);

    });

    // 编辑点滴信息
    $(document).on("click",".editdiary",function(e){
        var param   =   $(".modal-content > form").serialize();

        $.ajax(
            {
                url     :   "admin.php?ac=diary_class&op=setHotDiaryData",
                type    :   "POST",
                data    :   param,
                success :   function(data)
                {
                    if (data == 1) {
                        swal("编辑成功!", "该点滴已经被成功编辑！", "success");
                    }else{
                        swal("编辑失败!", "编辑该点滴时出现了问题！", "error");
                    }
                    refresh();
                }
            });
    });

    /*var curTime = Date.parse(new Date());
    curTime = curTime/1000;*/
    var myDate = new Date();
    var myHour = myDate.getHours();
    if(myHour < 12){
       $("#timeOnline option[value='no']").remove();
       $("#timeOnline option[value='16']").remove();
       $("#timeOnline option[value='20']").remove();
    }else if(myHour >= 12 && myHour < 16){
       $("#timeOnline option[value='no']").remove();
       $("#timeOnline option[value='all']").remove();
    }else if(myHour >= 16 && myHour < 20){
       $("#timeOnline option[value='no']").remove();
       $("#timeOnline option[value='all']").remove();
       $("#timeOnline option[value='16']").remove();
    }else if(myHour >= 20){
       $("#timeOnline option[value='all']").remove();
       $("#timeOnline option[value='16']").remove();
       $("#timeOnline option[value='20']").remove();
    }
    
    // 添加待上线热门点滴
    $(document).on("click",".addtohot",function(e){
        var param   =   $("#addDiaryToHotReady > form").serialize();
        var onTime = $("#timeOnline").val();
        if(onTime == "no"){
            swal("该时间段不可添加哦~!", "操作失败！", "error");
            return false;
        }
        $.ajax(
            {
                url     :   "admin.php?ac=diary_class&op=addHotDiaryData",
                type    :   "POST",
                data    :   param,
                success :   function(data)
                {
                    if (data == 1) {
                        swal("添加成功!", "该点滴已经被添加到热门待上线！", "success");
                    }else{
                        swal("添加失败!", "操作失败！", "error");
                    }
                    refresh();
                }
            });
    });

    $('#spinner4').spinner({value:0, step: 1, min: 1, max: 200});

    //var sheet = getQuerystring('index');
    var timet = $("#timet").val();
    var index = 0;
    if(timet == "12"){
        index = 1;
    }else if(timet == "16"){
        index = 2;
    }else if(timet == "20"){
        index = 3;
    }
    $(".select-sheet a:eq("+index+")").attr('class', 'btn btn-inverse');
    $(document).on("click",".select-sheet a", function(){
        $(".select-sheet a").attr('class', 'btn btn-default');
        $(this).attr('class', 'btn btn-inverse');
        var type = $(this).attr('name');
        window.location = location.origin+'/admin.php?ac=diary_class&op=hotReady&type='+type;
    });

    //批量删除
    $(document).on("click",".batchDelete",function(){
        var bodyId = '';
        var onlineTime = $("#timet").val();
        $("input[name='bodyId']:checked").each(function(i){
            bodyId += (","+$(this).val());
        });
        bodyId = bodyId.substring(1);  //截取逗号
        $.get(  "admin.php", {
            bodyId : bodyId,
            onlineTime : onlineTime,
            ac	   : 'diary_class',
            op	   : 'delHotDiaryByBodyId'
        },function(data) {
            if (data == 1) {
                alert('操作成功');
                refresh();
            }else{
                alert('操作失败');
            }
        });
    });

    //全选/全不选
    $(document).on("click",".checkAll",function(){
        $(".box").prop("checked", !$(".box").prop('checked'));
    });

    // 刷新当前页面
    function refresh(){
        setInterval(window.location.reload(),5000);
    }
</script>
</body>
</html>
